package com.huike.common.resultHandler;

import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;

import java.util.HashMap;
import java.util.Map;

public class CountHandler implements ResultHandler {
    private final Map<String, Integer> result = new HashMap();

    @Override
    public void handleResult(ResultContext resultContext) {
        Map map = (Map)resultContext.getResultObject();
        String key = (String) map.get("key");
        Long value = (Long) map.get("value");
        result.put(key, value.intValue());
    }

    public Map<String, Integer> getResult(){
        return result;
    }
}
